var HyvesBridge = {};

HyvesBridge.available = function()
{
	return true;
}

HyvesBridge.setFlashElement = function(id)
{
	HyvesBridge.swfId = id;
}

HyvesBridge.callAuthorize = function(url)
{
	HyvesBridge.authWin = window.open(url, 'hyvesAuthWin', 'width=500,height=500');
}

HyvesBridge.verify = function()
{
	var location = window.location.href;
	var token = decodeURIComponent(location.split('oauth_token=')[1].split('&oauth_verifier=')[0]);
	var verifier = decodeURIComponent(location.split('&oauth_verifier=')[1]);
	
	window.opener.HyvesBridge.passToken(token, verifier);
	window.close();
}

HyvesBridge.passToken = function(token, verifier)
{
	if (HyvesBridge.swfId)
	{
		document.getElementById(HyvesBridge.swfId).setToken(token, verifier);
	}
	else
	{
		alert('You never called HyvesBridge.setFlashElement');
	}
}